package com.comleader.utils;

import com.comleader.entity.response.ResponseEntity;
import com.comleader.entity.response.ResponseEnum;

/**
 * @Description: 响应封装工具类
 */
public class ResponseUtil {

    /**
     * 成功返回
     * @param object 返回数据
     * @return
     */
    public static ResponseEntity success(Object object){
        ResponseEntity resp = new ResponseEntity();
        resp.setCode(ResponseEnum.SUCCESS.getCode());
        resp.setMsg(ResponseEnum.SUCCESS.getMsg());
        resp.setData(object);
        return resp;
    }
    /**
     * 成功返回  无数据
     * @return
     */
    public static ResponseEntity success(){
        return success(null);
    }

    /**
     * 失败返回
     * @param responseEnum 响应标识
     * @return
     */
    public static ResponseEntity error(ResponseEnum responseEnum){
        ResponseEntity resp = new ResponseEntity();
        resp.setCode(responseEnum.getCode());
        resp.setMsg(responseEnum.getMsg());
        return resp;
    }

    /**
     * 失败返回
     * @param code
     * @param errmsg
     * @return
     */
    public static ResponseEntity error(int code,String errmsg){
        ResponseEntity resp = new ResponseEntity();
        resp.setCode(code);
        resp.setMsg(errmsg);
        return resp;
    }
}
